let mongoose = require('mongoose');

let record = new mongoose.Schema({
    roomId:Number, //房间ID
    createTime : Number, //完成时间
    endTime:Number,
    type : Number, //类型，是随机匹配还是什么
    roomType : Number,
    users:[require('./record.user')]
},{versionKey:false});

record.statics = {
    async getRecord(_id,time=Date.now()){
        let records = await this.find({users:{$elemMatch:{_id:_id}},endTime:{$gte:time}})
        return records
    }
};

module.exports = record;